<%--
	
This file is part of Annuaire.
 
Annuaire is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Annuaire is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Annuaire.  If not, see <http://www.gnu.org/licenses/>.

Document   : index
Created on : 31 mai 2011, 12:38:44
Author     : kemarion

--%>

<%@ taglib prefix="s" uri="/struts-tags" %>
<jsp:useBean scope="request" class="org.miage.annuaire.bean.StructuresBean" type="org.miage.annuaire.bean.StructuresBean" id="structuresBean" />
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<script type="text/javascript" src="resources/js/mootools-core-1.3.2-full-compat.js"></script>
<script type="text/javascript" src="resources/js/pdf.js"></script>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>
google.load('visualization', '1', {packages:['orgchart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
  var data = new google.visualization.DataTable();
  data.addColumn('string', 'Name');
  data.addColumn('string', 'Manager');
  data.addColumn('string', 'ToolTip');
  data.addRows( <%= structuresBean.getStructures() %>  );
  var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
  chart.draw(data, {allowHtml:true,  allowCollapse:true, size:'small'});
}

var buildQuery = function () {
	var query = "", input, i, allChecked = "true";
	input = document.getElementsByTagName('input');
	
	for (i = 0; i < input.length; i++) {
		if (input[i].type == "checkbox") {
			if (input[i].checked === true) {
				query = query + input[i].id + ",";
			} else {
				allChecked = "false";
			}	
		}
	}
	
	if (query.length > 0) {
		query = query.substring(0, query.length - 1);
	}
	
	document.getElementById("query").value = query;
	document.getElementById("allChecked").value = allChecked;
};
</script>

<h2 class="titre"><s:text name="global.pdfSelection"/></h2>

<div id="structures">
   <div id='chart_div'></div>
</div>

<div id="profondeure"></div>

<div id="pdf" align="center" style="margin-top: 20px;">
	<!-- <img style="border:0; cursor: pointer;" width="60px" alt="Generation PDF"  src="resources/images/pdf.png" title="<s:text name='global.pdfTitle'/>" onclick="generationPDF();" /> -->


<s:form>
	<s:hidden id="query" name="query" value=""/>
	<s:hidden id="allChecked" name="allChecked" value="true"/>
	<s:submit id="submitPdf" value="" action="downloadPdf"
			onclick="buildQuery()"/>
</s:form>
</div>
<s:actionerror />
